#define _CRT_SECURE_NO_WARNINGS 1

int GetNext(char ch[], int length, int next[])
{
	int i = 1;
	int j = 0;
	next[1] = 0;
	while (i <= length)
	{
		if (j == 0 || ch[i] == ch[j])
		{
			next[++i] = ++j
		}
		else
		{
			j = next[j];
		}
	}
}